﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.Composition;
using Core.DataAccess;
using SonCa.SocialNetwork.Web.ASCX.IPresenters;
using Core.Interfaces;
using Core.BusinessLogic.Interfaces;
using Core.Common;
using SonCa.SocialNetwork.Web.HelperClass;

namespace SonCa.SocialNetwork.Web.ASCX.Presenters
{
    [Export(typeof(IProfileDisplay))]
    public class ProfileDisplayPresenter
    {
        private IProfileDisplay _view;
        [Import]
        private IUserSession _userSession;        
        [Import]
        private IFriendInvitationService _friendInvitationService;               

        public ProfileDisplayPresenter()
        {
        }
        public void Init(IProfileDisplay view)
        {
            _view = view;
            MEFManager.Compose(this);
            Account currentUser = _userSession.CurrentUser as Account;

            if (currentUser != null)
            {
                List<File> files = new List<File>();
                files.RemoveAll(n => n == null);
                _view.LoadPhotos(Translator.FileToHCFile(files));
            }
        }

        public void SendFriendRequest(Int32 AccountIDToInvite)
        {
            _friendInvitationService.SaveFriendInvitation(new FriendsInvitation { CreateDate = DateTime.Now, AccountID = _userSession.CurrentUser.AccountID, BecameAccountID = AccountIDToInvite });
        }        
    }
}